<?php

if (isset($_POST['prc_procedure']) && $_POST['prc_procedure'] == 1) {
$GLOBALS['MYT']->db_query("INSERT INTO hd_amlprocess (amp_Time, amp_User, amp_Status, amp_Client, amp_Description, amp_total, amp_quant)
	 VALUES ('$sysTime',$_SESSION[$SESSID],1,$SenderID,'',0,0)");
} elseif (isset($_POST['prc_procedure']) && $_POST['prc_procedure'] == 2) {
	
$_POST['amp_Description'] = req_form($_POST['amp_Description']);
	$GLOBALS['MYT']->db_query("UPDATE hd_amlprocess 
						SET amp_Description = '{$_POST['amp_Description']}', 
						amp_Status = {$_POST['amp_Status']},
						amp_total = amp_total+{$_POST['P1']},
						amp_quant = amp_quant+{$_POST['P2']}
						WHERE amp_ID = {$_POST['prc_open']}");
	
	$m = 1;
	$t = 0;
	if ($_POST['POOL'] != '') {
	$Qprc = 'INSERT INTO facturas_pbc (frp_FraID,frp_PbcID) VALUES ';
	$ORPool = substr($_POST['POOL'],0,strlen($_POST['POOL'])-1);
	$Pool = preg_split('/,/',$ORPool);
	$Cpool = count($Pool);
	for($p = 0; $p<$Cpool; $p++) {
	$Qprc .= '('.$Pool[$p].','.$_POST['prc_open'].')';
		if ($p < $Cpool-1) {
			$Qprc .= ',';
		}
	}
	$GLOBALS['MYT']->db_query($Qprc);
	$_POST['POOL'] = '';
	}
	if (isset($_POST['prc_docs'])) {
	$Qdocs = 'INSERT INTO hd_amlprdoc (add_prID,add_DocID,add_DocDocID) VALUES ';
	$Docs = $_POST['prc_docs'];
	$Cdocs = count($Docs);
	for($p = 0; $p<$Cdocs; $p++) {
	$Qdocs .= '('.$_POST['prc_open'].','.$Docs[$p].',1)';
		if ($p < $Cdocs-1) {
			$Qdocs .= ',';
		}
	}
	$GLOBALS['MYT']->db_query($Qdocs);
	}
	if (isset($_POST['prc_docsAML'])) {
	$Qdocs = 'INSERT INTO hd_amlprdoc (add_prID,add_DocID,add_DocDocID) VALUES ';
	$Docs = $_POST['prc_docsAML'];
	$Cdocs = count($Docs);
	for($p = 0; $p<$Cdocs; $p++) {
	$Qdocs .= '('.$_POST['prc_open'].','.$Docs[$p].',2)';
		if ($p < $Cdocs-1) {
			$Qdocs .= ',';
		}
	}
	$GLOBALS['MYT']->db_query($Qdocs);
	}
	
}